<#import "/layout/mainLayout.html" as mainLayout />

<#macro mainheading>

</#macro>
<#assign mainheading = mainheading in mainLayout />

<#macro maincontent>


    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <div class="row">
                            <div class="col-sm-12" id="filmtypecontent">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-2">
                                <select class="form-control" id="input_classType">
                                    <option value="-1">--视频的类型--</option>
                                    <option value="1">电影</option>
                                    <option value="2">电视剧</option>
                                    <option value="3">综艺</option>
                                    <option value="4">动漫</option>
                                </select>
                            </div>
                            <div class="col-sm-1 pull-right">
                                <button class="btn btn-block btn-default " id ="btn_search" onclick="searchTopLogList()">查询
                                </button>
                            </div>
                        </div><!-- /.box-header -->
                    </div>

                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>视频名称</th>
                                <th>视频类型</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody id="bodycontent">


                            </tbody>
                        </table>
                    </div><!-- /.box-body -->
                    <div id="pagecontent" class="pagination"></div>
                </div><!-- /.box -->
            </div>
        </div>
    </section>

</#macro>
<#assign maincontent = maincontent in mainLayout />

<#macro mainfooter>
    <!--layoutmain footer...-->
    <!--<br />-->

    <script type="text/javascript">
        var topLog_data = {};
        function searchTopLogList() {

            topLog_data = {
                classType:$('#input_classType').val(),
                pno: 1,
                pagesize: 10,
                allcount:-1
            };
            LoadTopLogList();
        }
        //加载列表
        searchTopLogList();
        function LoadTopLogList() {
            $('#pagecontent').html('');
            $.ajax({
                    url: '/api/video/getTodaylist',
                    data: topLog_data,
                    type: 'POST',
                    contentType: "application/x-www-form-urlencoded",
                    dataType: 'json',
                    success: function (data) {
                        if (mortise_layout.ValidataResult(data)) {
                            if (data.result) {
                                topLog_data.allcount = data.result.count;
                                var html = '';
                                $.each(data.result.list, function (index, item) {
                                    html += getHtml(item);
                                })
                                $('#bodycontent').html(html);
                                ShowPage('pagecontent', topLog_data, function (pno) {
                                    topLog_data.pno = pno;
                                    LoadTopLogList();
                                });
                            }
                            else {
                                alert('返回数据错误！');
                            }
                        }
                        else {
                            alert('请求数据失败！');
                        }
                    }
                }
            );
        }

        function  getHtml(dataObject) {

            var fClasstype='';
            if('1'==dataObject.fClasstype){
                fClasstype = '电影';
            }else if ('2'==dataObject.fClasstype){
                fClasstype = '电视剧';
            }else if ('3'==dataObject.fClasstype){
                fClasstype = '综艺';
            }else if ('4'==dataObject.fClasstype){
                fClasstype = '动漫';
            }



            return ' <tr>'+
                '<td>'+dataObject.fName+'</td>'+
                '<td>'+fClasstype+'</td>'+
                '<td>'+dataObject.fIntime+'</td>'+
                '<td>'+'<a style="cursor: pointer" href="#" onclick="upToday(\''+dataObject.fId+'\')">置顶</a>&nbsp;&nbsp' +
                '<a style="cursor: pointer" href="#" onclick="delToday(\''+dataObject.fId+'\')">删除</a>' +'</td></tr>';
        }



        function upToday(fid) {
            $.ajax({
                    url: '/api/video/upToday',
                    data: {fid: fid},
                    type: 'POST',
                    contentType: "application/x-www-form-urlencoded",
                    dataType: 'json',
                    success: function (data) {
                        if (data) {
                            if (data.code=='OperateOk'){
                                dialog({
                                    title:'提示',
                                    content: '操作成功！',
                                    cancel: false,
                                    ok: function () {}
                                }).width(320).showModal();
                                LoadTopLogList();
                            }
                            else{
                                dialog({
                                    title:'提示',
                                    content: '操作失败！',
                                    cancel: false,
                                    ok: function () {}
                                }).width(320).showModal();
                            }
                        }
                        else {
                            alert('请求数据失败！');
                        }
                    }
                }
            );
        }


        function delToday(fid) {
            $.ajax({
                    url: '/api/video/delToday',
                    data: {fid: fid},
                    type: 'POST',
                    contentType: "application/x-www-form-urlencoded",
                    dataType: 'json',
                    success: function (data) {
                        if (data) {
                            if (data.code=='OperateOk'){
                                dialog({
                                    title:'提示',
                                    content: '操作成功！',
                                    cancel: false,
                                    ok: function () {}
                                }).width(320).showModal();
                                LoadTopLogList();
                            }
                            else{
                                dialog({
                                    title:'提示',
                                    content: '操作失败！',
                                    cancel: false,
                                    ok: function () {}
                                }).width(320).showModal();
                            }
                        }
                        else {
                            alert('请求数据失败！');
                        }
                    }
                }
            );
        }
    </script>
</#macro>
<#assign mainfooter = mainfooter in mainLayout />
<@mainLayout.page title="用户管理"/>